package com.siterwell.push.service.impl;

import com.siterwell.push.dao.DeviceDao;
import com.siterwell.push.entity.DevLog;
import com.siterwell.push.entity.JPushLog;
import com.siterwell.push.entity.SubDevAddLog;
import com.siterwell.push.mongodao.MongoAddSubDevLogDao;
import com.siterwell.push.mongodao.MongoDevLogDao;
import com.siterwell.push.mongodao.MongoJpushLogDao;
import com.siterwell.push.service.IDeviceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.util.List;

@Service
public class DevLogService implements IDeviceLogService {
    @Autowired
    private MongoDevLogDao mongoDevLogDao;

    @Autowired
    private MongoAddSubDevLogDao mongoAddSubDevLogDao;

    @Autowired
    private MongoJpushLogDao mongoJpushLogDao;

    @Autowired
    private DeviceDao deviceDao;


    @Async("asyncExecutor")
    @Override
    public void insertDevLog(DevLog devLog) {
        mongoDevLogDao.saveDevLog(devLog);
    }


    @Async("asyncExecutor")
    @Override
    public void insertAddSubDevLog(SubDevAddLog subDevAddLog) {

        mongoAddSubDevLogDao.saveDevLog(subDevAddLog);
//        deviceDao.saveSubDevice(subDevAddLog);
    }

    @Async("asyncExecutor")
    @Override
    public void insertJpushLog(JPushLog jPushLog) {
        mongoJpushLogDao.saveJpushLog(jPushLog);
    }


}
